import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ParameterVO, ParameterForm, ParameterQuery } from '@/api/module/parameter/types';

/**
 * 查询配置参数列表
 * @param query
 * @returns {*}
 */

export const listParameter = (query?: ParameterQuery): AxiosPromise<ParameterVO[]> => {
  return request({
    url: '/module/parameter/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询配置参数详细
 * @param id
 */
export const getParameter = (id: string | number): AxiosPromise<ParameterVO> => {
  return request({
    url: '/module/parameter/' + id,
    method: 'get'
  });
};

/**
 * 新增配置参数
 * @param data
 */
export const addParameter = (data: ParameterForm) => {
  return request({
    url: '/module/parameter',
    method: 'post',
    data: data
  });
};

/**
 * 修改配置参数
 * @param data
 */
export const updateParameter = (data: ParameterForm) => {
  return request({
    url: '/module/parameter',
    method: 'put',
    data: data
  });
};

/**
 * 删除配置参数
 * @param id
 */
export const delParameter = (id: string | number | Array<string | number>) => {
  return request({
    url: '/module/parameter/' + id,
    method: 'delete'
  });
};
